package com.qjc.mq.controller;

import com.qjc.mq.producer.Producer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: MqMessageController
 * @Description:
 * @Author: qjc
 * @Date: 2021/12/13 11:41 上午
 */
@RestController
@RequestMapping
public class MqMessageController {

    @Autowired
    private Producer producer;

    /**
     * http://localhost:8803/push/message
     */
    @RequestMapping("/push/message")
    public void push() {
        for (int id = 1; id <= 10; id++) {
            producer.push(id);
        }
    }

    /**
     * http://localhost:8803/push/sync/message
     */
    @RequestMapping("/push/sync/message")
    public void pushSyncMessage() {
        for (int id = 1; id <= 10; id++) {
            producer.pushSyncMessage(id);
        }
    }

    /**
     * http://localhost:8803/push/async/message
     */
    @RequestMapping("/push/async/message")
    public void pushAsyncMessage() {
        for (int id = 1; id <= 10; id++) {
            producer.pushAsyncMessage(id);
        }
    }

    /**
     * http://localhost:8803/push/oneway/message
     */
    @RequestMapping("/push/oneway/message")
    public void pushOneWayMessage() {
        for (int id = 1; id <= 10; id++) {
            producer.pushOneWayMessage(id);
        }
    }

    /**
     * http://localhost:8803/push/sequence/message
     */
    @RequestMapping("/push/sequence/message")
    public void pushSequenceMessage() {
        // 发送10个订单
        for (int id = 1; id <= 10; id++) {
            producer.pushSequenceMessage(id);
        }
    }

    /**
     * http://localhost:8803/push/delay/message
     */
    @RequestMapping("/push/delay/message")
    public void pushDelayMessage() {
        for (int id = 1; id <= 10; id++) {
            producer.pushDelayMessage(id);
        }
    }

    /**
     * http://localhost:8803/push/batch/message
     */
    @RequestMapping("/push/batch/message")
    public void pushBatchMessage() {
        for (int id = 1; id <= 10; id++) {
            producer.pushBatchMessage(id);
        }
    }

    /**
     * http://localhost:8803/push/sql/message
     */
    @RequestMapping("/push/sql/message")
    public void pushSqlMessage() {
        for (int id = 1; id <= 10; id++) {
            producer.pushSqlMessage(id);
        }
    }

    /**
     * http://localhost:8803/push/transaction/message
     */
    @RequestMapping("/push/transaction/message")
    public void pushTransactionMessage() {
        for (int id = 1; id <= 10; id++) {
            producer.pushTransactionMessage(id);
        }
    }

}
